/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package pt.iasd.youthshelter.datamodel;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Rui
 */
@Entity
@Table(name = "INVESTITURE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Investiture.findAll", query = "SELECT i FROM Investiture i"),
    @NamedQuery(name = "Investiture.findById", query = "SELECT i FROM Investiture i WHERE i.id = :id"),
    @NamedQuery(name = "Investiture.findByEventDate", query = "SELECT i FROM Investiture i WHERE i.eventDate = :eventDate"),
    @NamedQuery(name = "Investiture.findByPlace", query = "SELECT i FROM Investiture i WHERE i.place = :place")})
public class Investiture implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Column(name = "EVENT_DATE")
    @Temporal(TemporalType.DATE)
    private Date eventDate;
    @Size(max = 200)
    @Column(name = "PLACE")
    private String place;
    @JoinTable(name = "INVESTITURE_CLASS", joinColumns = {
        @JoinColumn(name = "INVESTITURE_ID", referencedColumnName = "ID")}, inverseJoinColumns = {
        @JoinColumn(name = "CLASS_ID", referencedColumnName = "ID")})
    @ManyToMany
    private List<ProgressiveClass> progressiveClassList;
    @JoinTable(name = "INVESTITURE_HONOR", joinColumns = {
        @JoinColumn(name = "INVESTITURE_ID", referencedColumnName = "ID")}, inverseJoinColumns = {
        @JoinColumn(name = "HONOR_ID", referencedColumnName = "ID")})
    @ManyToMany
    private List<Honor> honorList;
    @JoinTable(name = "INVESTITURE_CLUB", joinColumns = {
        @JoinColumn(name = "INVESTITURE_ID", referencedColumnName = "ID")}, inverseJoinColumns = {
        @JoinColumn(name = "CLUB_ID", referencedColumnName = "ID")})
    @ManyToMany
    private List<Club> clubList;
    @JoinColumn(name = "PATHFINDER_ID", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private Pathfinder pathfinderId;
    @JoinColumn(name = "LIDER_ID", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private Lider liderId;

    public Investiture() {
    }

    public Investiture(Integer id) {
        this.id = id;
    }

    public Investiture(Integer id, Date eventDate) {
        this.id = id;
        this.eventDate = eventDate;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getEventDate() {
        return eventDate;
    }

    public void setEventDate(Date eventDate) {
        this.eventDate = eventDate;
    }

    public String getPlace() {
        return place;
    }

    public void setPlace(String place) {
        this.place = place;
    }

    @XmlTransient
    public List<ProgressiveClass> getProgressiveClassList() {
        return progressiveClassList;
    }

    public void setProgressiveClassList(List<ProgressiveClass> progressiveClassList) {
        this.progressiveClassList = progressiveClassList;
    }

    @XmlTransient
    public List<Honor> getHonorList() {
        return honorList;
    }

    public void setHonorList(List<Honor> honorList) {
        this.honorList = honorList;
    }

    @XmlTransient
    public List<Club> getClubList() {
        return clubList;
    }

    public void setClubList(List<Club> clubList) {
        this.clubList = clubList;
    }

    public Pathfinder getPathfinderId() {
        return pathfinderId;
    }

    public void setPathfinderId(Pathfinder pathfinderId) {
        this.pathfinderId = pathfinderId;
    }

    public Lider getLiderId() {
        return liderId;
    }

    public void setLiderId(Lider liderId) {
        this.liderId = liderId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Investiture)) {
            return false;
        }
        Investiture other = (Investiture) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pt.iasd.youthshelter.datamodel.Investiture[ id=" + id + " ]";
    }
    
}
